using System;
using System.Collections.Generic;
using System.Text;
using DTO;
using DAL;
using Utility;

namespace BUS
{
    public class CauHoiBinhLuan_BUS
    {
        public static void Insert(CauHoiBinhLuan_DTO cauHoiBinhLuan)
        {
            CauHoiBinhLuan_DAL cauHoiBinhLuanDAL = new CauHoiBinhLuan_DAL();
            cauHoiBinhLuanDAL.Insert(cauHoiBinhLuan);
        }
        public static void Update(CauHoiBinhLuan_DTO cauHoiBinhLuan)
        {
            CauHoiBinhLuan_DAL cauHoiBinhLuanDAL = new CauHoiBinhLuan_DAL();
            cauHoiBinhLuanDAL.Update(cauHoiBinhLuan);
        }
        public static void Delete(int iD)
        {
            CauHoiBinhLuan_DAL cauHoiBinhLuanDAL = new CauHoiBinhLuan_DAL();
            cauHoiBinhLuanDAL.Delete(iD);
        }
        public static tbCauHoiBinhLuanCollection Get(string where,
            int pageindex,
            int pagesize,
            string orderby,
            string orderdirection,
            out int total)
        {
            CauHoiBinhLuan_DAL cauHoiBinhLuanDAL = new CauHoiBinhLuan_DAL();
            return cauHoiBinhLuanDAL.Get(where, pageindex, pagesize, orderby, orderdirection, out total);
        }
        public static tbCauHoiBinhLuanCollection GetAll()
        {
            int total = 0;
            Criteria cri = new Criteria();
            CauHoiBinhLuan_DAL cauHoiBinhLuanDAL = new CauHoiBinhLuan_DAL();
            return cauHoiBinhLuanDAL.Get(cri.Criter, 0, 0, tbCauHoiBinhLuanColumns.ID.ToString(), OrderDirection.ASC.ToString(), out total);
        }
        public static CauHoiBinhLuan_DTO GetByID(int iD)
        {
            int total = 0;
            Criteria cri = new Criteria();
            cri.add(Condition.AND, tbCauHoiBinhLuanColumns.ID.ToString(), Condition.EQUAL, iD);
            CauHoiBinhLuan_DAL cauHoiBinhLuanDAL = new CauHoiBinhLuan_DAL();
            tbCauHoiBinhLuanCollection cauHoiBinhLuanCollection = cauHoiBinhLuanDAL.Get(cri.Criter,
                0, 0, tbCauHoiBinhLuanColumns.ID.ToString(), OrderDirection.ASC.ToString(), out total);
            if (cauHoiBinhLuanCollection.Count > 0)
                return cauHoiBinhLuanCollection[0];
            return null;
        }
        public static tbCauHoiBinhLuanCollection GetLimited(int number)
        {
            int total = 0;
            Criteria cri = new Criteria();
            CauHoiBinhLuan_DAL cauHoiBinhLuanDAL = new CauHoiBinhLuan_DAL();
            return cauHoiBinhLuanDAL.Get(cri.Criter, 1, number,
                tbCauHoiBinhLuanColumns.ID.ToString(), OrderDirection.DESC.ToString(), out total);
        }
        public static tbCauHoiBinhLuanCollection GetPromotion(int number)
        {
            int total = 0;
            Criteria cri = new Criteria();
            CauHoiBinhLuan_DAL cauHoiBinhLuanDAL = new CauHoiBinhLuan_DAL();
            return cauHoiBinhLuanDAL.Get(cri.Criter, 1, number,
                tbCauHoiBinhLuanColumns.ID.ToString(), OrderDirection.DESC.ToString(), out total);
        }
    }
}
